package com.ruibang.glass.quality.controller.semi;

import com.ruibang.glass.quality.domain.resp.DiagramData;
import com.ruibang.glass.quality.domain.req.QualityThicknessReq;
import com.ruibang.glass.quality.domain.resp.ThicknessExcelDataResp;
import com.ruibang.glass.quality.entity.QualityThickness;
import com.ruibang.glass.quality.service.QualityThicknessService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import com.teaming.cloud.framework2.common.pojo.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


/**
 * <p>
 * 半成品厚度信息 前端控制器
 * </p>
 *
 * @author wujie
 * @since 2024-03-11
 */
@RestController

@RequestMapping("/api/quality/thickness")
@Api(value="半成品厚度信息控制器",tags={"半成品厚度信息接口"})
public class QualityThicknessController {

    
    @Autowired
    private QualityThicknessService qualityThicknessService;

    /**
    * 通过id查询
    */
    @GetMapping("/getById/{id}")
    @ApiOperation(value="获取质量半成品厚度信息",notes="获取质量半成品厚度信息")
    public ResultBody getById(@PathVariable(value = "id") String id){
        return ResultBody.success(qualityThicknessService.getById(id));
    }

    /**
    * 新增
    */
    @PostMapping("/save")
    @ApiOperation(value="新增质量半成品厚度信息",notes="新增质量半成品厚度信息")
    public ResultBody save(@RequestBody QualityThickness qualityThickness){
        qualityThicknessService.saveInfo(qualityThickness);
        return ResultBody.success();
    }

    /**
    * 通过id删除
    */
    @GetMapping("/deleteById/{id}")
    @ApiOperation(value="通过ID删除质量半成品厚度信息",notes="通过ID删除质量半成品厚度信息")
    public ResultBody delete(@PathVariable(value = "id") String id){
        qualityThicknessService.delete(id);
        return ResultBody.success();
    }

    /**
    * 修改
    */
    @PostMapping("/update")
    @ApiOperation(value="修改质量半成品厚度信息",notes="修改质量半成品厚度信息")
    public ResultBody updateById(@RequestBody QualityThickness qualityThickness){
        qualityThicknessService.updateInfo(qualityThickness);
        return ResultBody.success();
    }


    /**
    * 查询列表
    */
    @PostMapping("/list")
    @ApiOperation(value="非分页列表查询质量半成品厚度信息",notes="非分页列表查询质量半成品厚度信息")
    public ResultBody list(@RequestBody QualityThicknessReq qualityThickness ){
        return ResultBody.success(qualityThicknessService.queryQualityThickness(qualityThickness));
    }

    /**
    * 分页查询
    */
    @PostMapping("/page")
    @ApiOperation(value="分页列表查询质量半成品厚度信息",notes="分页列表查询质量半成品厚度信息")
    public ResultBody page(@RequestBody PageRequest<QualityThicknessReq> pageParam){
        return ResultBody.success(qualityThicknessService.queryPage(pageParam));
    }

    @GetMapping("/lineGraph/{thicknessId}")
    @ApiOperation(value="折线图",notes="折线图")
    public ResultBody<List<DiagramData>> lineGraph(@PathVariable("thicknessId") String thicknessId){
        return ResultBody.success(qualityThicknessService.lineGraph(thicknessId));
    }

/*
    @PostMapping("/tendencyChart")
    @ApiOperation(value="折线图",notes="折线图")
    public ResultBody<> tendencyChart(@PathVariable("thicknessId") String thicknessId){
        return ResultBody.success(qualityThicknessService.lineGraph(thicknessId));
    }
*/


    @PostMapping("/importThickness")
    @ApiOperation(value="导入半成品厚度信息excel",notes="导入半成品厚度信息excel")
    public ResultBody<ThicknessExcelDataResp> importThickness(@RequestPart("files") List<MultipartFile> files){
        return ResultBody.success(qualityThicknessService.importThickness(files));
    }
}
